package KDTreeIndex;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

import Acquaintance.IAHouse;
import Control.CCache;


public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		HashMap<String, IAHouse> map=CCache.getCache().getHouseMap();
		Iterator<String> iterator = map.keySet().iterator();
		HashMap<Key,ArrayList<Integer>> Data=new HashMap<Key,ArrayList<Integer>>();
		while(iterator.hasNext()) {
			IAHouse house=map.get(iterator.next());
			Key key=new Key(3);
			key.setKey(DataImport.getKey(house.getType()));
			if(Data.containsKey(key))
			{
				Data.get(key).add(house.getHID());
			}
			else
			{

				ArrayList<Integer> HIDs=new ArrayList<Integer>();
				HIDs.add(house.getHID());
				Data.put(key, HIDs);
			}
			}
		KDTree kdtree=new KDTree(3);
		kdtree.buildTree(Data);
		Key key =new Key(3);
		int[] k={2,2,1};
		key.setKey(DataImport.getKey("3室2厅1卫"));
		System.out.println(DataImport.check("3室2厅1卫"));
		System.out.println(kdtree.Search(key));
	}

}
